home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-10-08 | 1.2 KB | 25 lines | [TEXT/MSBA] |
- 10 CLS:PRINT"COMAT MULTIPLIES 2 COMPLEX 2*2 MATRICES, |A|*|B|=|R|":PRINT"DEFINE A(J,K)=A(ROW,COL)":PRINT"PUT 2nd COLUMN=0 FOR SINGLE COLUMN MATRIX"
- 15 DIM A(2,2),B(2,2),C(2,2),D(2,2),R(2,2),I(2,2)
- 17 INPUT "ARE ALL TERMS REAL(Y/N)=";R$
- 19 FOR J=1 TO 2:FOR K=1 TO 2
- 20 PRINT"NEW REAL A(";J;K;")=";:INPUT A(J,K):IF R$="Y" THEN 27
- 25 PRINT"NEW IMAG A(";J;K;")=";:INPUT C(J,K)
- 27 NEXT K:NEXT J
- 28 IF M$="B" THEN 39
- 29 PRINT:FOR J=1 TO 2:FOR K=1 TO 2
- 30 PRINT"NEW REAL B(";J;K;")=";:INPUT B(J,K):IF R$="Y" THEN 37
- 35 PRINT"NEW IMAG B(";J;K;")=";:INPUT D(J,K)
- 37 NEXT K:NEXT J
- 39 FOR J=1 TO 2:FOR K=1 TO 2:R(J,K)=0:I(J,K)=0:NEXT K:NEXT J
- 40 PRINT:PRINT"RESULT MATRIX=|(REAL+i*IMAG)|":FOR J=1 TO 2:FOR K=1 TO 2:FOR L=1 TO 2
- 45 R(J,K)=R(J,K)+A(J,L)*B(L,K)-C(J,L)*D(L,K)
- 50 I(J,K)=I(J,K)+A(J,L)*D(L,K)+C(J,L)*B(L,K):NEXT L
- 55 PRINT"REAL(";J;K;")=";R(J,K):IF R$="Y" THEN 65
- 60 PRINT"IMAG(";J;K;")=";I(J,K)
- 65 NEXT K:NEXT J
- 70 PRINT"END,UNLESS ANOTHER MATRIX OPERATION NEEDED:":INPUT "SWOP |R| WITH |A| OR |B|=";M$
- 75 IF M$="B" THEN GOSUB 85:GOTO 19
- 80 FOR J=1 TO 2:FOR K=1 TO 2:A(J,K)=R(J,K):C(J,K)=I(J,K):NEXT K:NEXT J:GOTO 29
- 85 FOR J=1 TO 2:FOR K=1 TO 2:B(J,K)=R(J,K):D(J,K)=I(J,K):NEXT K:NEXT J:RETURN
- MACINTOSH LISTING
-